<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9" />
<title>Gwack Admin</title>
<link href="style.css" rel="stylesheet" type="text/css" />

</head>
<body>
<div id="container">
<?php include("menu.php"); ?>



<div id="content">
    <div id="leftBox">
        <div class="contentBox">
            <div class="innerContent">



<?php

$tar = $_GET['tar'];
$gwname = $_GET['name'] or die ("why");
$restorepath = $_GET['restore'];
$gwtarpath = $_GET['gwtarpath'];
$tardate = substr($tar, 0, 8);


$tarrestorepath = $_GET['tarrestorepath']."/".$tardate;

$tardate = substr($tar, 0, 8);


if (substr($gwtarpath, -1) == "/")
{
	$tarfile = $gwtarpath.$tar;
}
else
{
	$tarfile = $gwtarpath."/".$tar;
}
$cmd = "sudo /opt/gwack/restoretar.sh $tarfile $tarrestorepath $restorepath";

$out = shell_exec($cmd) or die("Failed to execute script");

if ($out == 0)
{
	$configfile = '/etc/opt/gwack/gwack.xml';
	$x = simplexml_load_file($configfile);
	foreach ($x->server as $s)
	{
		if ($s->name == $gwname)
		{
		$s->restorepath = $tarrestorepath;
		file_put_contents($configfile, $x->asXML()) or die("save failed");

		}	
   }
	echo '<div class="successBox">';
	echo '<div class="successBoxTop">&nbsp;</div>';
	echo '<div class="msgBoxContent successIcon">';
	echo '<p>Success!';
	echo " $gwname restore path reset to:<strong> $restorepath/$newrestore</strong></p>";
	echo '</div></div></div>';
}

else
{
	echo '<div class="errorBox"><div class="errorBoxTop">&nbsp;</div>';
    echo '<div class="msgBoxContent errorIcon">';
    echo '<p>Error. Restore failed. </p>';
    echo '</div></div></div>';

}

?>

</div></div></div></div>

</body></html>
<?php include 'footer.html'; ?>
